<template>
  <div class="about">
    <h1>This is an about page</h1>
    <button @click="changeData">{{ this.$store.state.a.countA }}</button>
    {{ this.isLogin }}

    <button @click="login">loginJson:{{ this.loginJson }}</button>
    <button @click="userInfo">userInfo:{{ this.userInfoJson }}</button>
  </div>
</template>

<script>
export default {
  name: "about",
  data() {
    return {
      isLogin: 0,
      loginJson: {},
      userInfoJson: {}
    };
  },
  methods: {
    changeData() {
      // this.isLogin = this.$store.getters.doubleCountA;
      this.$store.dispatch("incrementAFun", 2);
      //this.$store.dispatch("incrementAFun");
    },
    login() {
      let _this = this;
      // this.$http("/API_MOCK" + this.$API.LOGIN, "");
      this.$http({
        url: this.$http.adornUrl(this.$API.LOGIN),
        method: "post",
        params: this.$http.adornParams({
          username: "admin",
          password: "123456"
        })
      }).then(({ data }) => {
        _this.loginJson = data;
      });
    },
    userInfo() {
      let _this = this;
      this.$http({
        url: this.$http.adornUrl(this.$API.GET_INFO),
        method: "post",
        data: this.$http.adornData({
          username: "admin",
          password: "123456"
        })
      })
        .then(({ data }) => {
          console.log(data);
          _this.userInfoJson = data;
        })
        .catch(err => {
          console.log(err);
        });
    }
  }
};
</script>
